<template>
    <div>
       <el-breadcrumb separator-class="el-icon-arrow-right">
  <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item> 
  <el-breadcrumb-item>订单管理</el-breadcrumb-item> 
  <el-breadcrumb-item>订单列表</el-breadcrumb-item> 
</el-breadcrumb>  <br> 
<el-card> 
<div class="ss"> <el-input placeholder="输入要搜素的内容" @input="search" v-model="user.query"></el-input> <el-button icon="el-icon-search" type="info" ></el-button></div> <br><br> 

 <el-table  :data="tableData"  style="width: 100%"> 
      <el-table-column type="index" label="#"> </el-table-column>
      <el-table-column prop="order_number"  label="订单编号"></el-table-column>
      <el-table-column  prop="order_price" label="订单价格"> </el-table-column>
      <el-table-column label="是否付款"> 
          <template slot-scope="scope"> 
              <el-tag  :type="obj[scope.row.pay_status]" > {{scope.row.pay_status | pay}} </el-tag>
          </template> 
      </el-table-column>
      <el-table-column  prop="is_send" label="是否发货"> </el-table-column> 
      <el-table-column  label="下单时间">
           <template slot-scope="scope">
                {{scope.row.create_time |  dateTime}}
           </template>
      </el-table-column>
      <el-table-column label="操作"> 
          <template slot-scope="scope"> 
                <el-button type="primary" icon="el-icon-edit" circle @click="xiugai"></el-button>
                <el-button type="info" icon="el-icon-location-outline" circle @click="lookwuliu"></el-button>
          </template> 
      </el-table-column> 
    </el-table>
</el-card> <br>

 <div class="block">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="user.pagenum"
      :page-sizes="[6, 20, 30, 40]"
      :page-size="user.pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>

<!-- 修改的模态框 -->

<el-dialog title="修改地址" :visible.sync="dialogFormVisible">
  <el-form>
       <el-form-item label="省市区/县" >
            <el-cascader
    v-model="checkedArr"
    :options="city"
    :props="{ expandTrigger: 'hover' }"
    @change="handleChange"></el-cascader>
    </el-form-item> 
    <el-form-item label="详细地址" >
        <el-input></el-input>  
    </el-form-item> 
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button @click="dialogFormVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
  </div>
</el-dialog> 


<!-- 查看物流进度 -->

<el-dialog title="物流进度" :visible.sync="dialogFormVisibles">
  <el-form> 
        <el-timeline :reverse="false">
    <el-timeline-item
    :icon="item.icon"
    :color="item.color"
      v-for="(item, index) in wuliu"
      :key="index"
      :timestamp="item.time">         
      {{item.context}}
    </el-timeline-item>
  </el-timeline>

  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button @click="dialogFormVisibles = false">取 消</el-button>
    <el-button type="primary" @click="dialogFormVisibles = false">确 定</el-button>
  </div>
</el-dialog> 

    </div>
</template> 
<script>
import city from '../assets/city.js'
import wuliu from '../assets/wuliu.js'
console.log(city)
console.log('物流',wuliu)
export default {
  data() {
    return {
     tableData:[] , //表格的数据
      city,
      wuliu:wuliu.data,
      total:0,
      user:{
          query:'',
          pagenum:1,
          pagesize:6,
      },
      obj:{
          0:'danger', 
          1:'primary',
          2:'warning'
      },
      dialogFormVisible:false,  //修改地址模态框
      form:[] ,   //级联框的数据
      checkedArr:[] , //级联狂选中的值
      options:[] , //级联狂绑定的内容
      dialogFormVisibles:false,
    };
  },
  mounted(){ 
      this.getlist()
  },
  methods:{
      //搜索
  
       async getlist(){
           const res=await this.$API.getordersApi(this.user)
        //    console.log(res) 
           let {goods,total}=res
           this.tableData=goods
           this.total=total
           
       },
        handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
        this.user.pagesize=val
        this.getlist()
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
        this.user.pagenum=val
         this.getlist()
      },
      //点击修改  
      xiugai(){
           this.dialogFormVisible=true
      },
      //查看物流
      lookwuliu(){
         this.dialogFormVisibles=true
      },
      handleChange(){},
  },
  computed:{
         search(){
          if(this.user.query!==''){ 
               this.tableData=this.tableData.filter(item=>{
                   return item.order_number.indexOf(this.user.query)>-1
               })
          }else{
               this.getlist() 
          }
      },
  }
};
</script>

<style scoped >
.el-input {
  width: 350px;
}
.ss {
  display: flex;
}
</style>
